import { IsString, IsInt, IsEthereumAddress, IsOptional } from 'class-validator';
import { Transform } from 'class-transformer';

export class SaveUserDto {

    @IsOptional() // 可选
    @IsInt()
    @Transform(({ value }) => value || '0') // 缺省时设置默认值
    readonly id: number;

    @IsEthereumAddress()
    readonly address: string;

    @IsOptional()
    @IsString()
    @Transform(({ value }) => value || '')
    readonly real_name: string;

    @IsString()
    @Transform(({ value }) => value || '')
    readonly nick_name: string;

    @IsOptional()
    @IsInt()
    @Transform(({ value }) => value || '0')
    readonly age: number;

}

export class DelUserDto {
    
    @IsInt()
    readonly id: number;

    @IsOptional() // 可选
    @IsEthereumAddress()
    readonly address: string;
}